/*
* @Author: anchen
* @Date:   2016-07-08 17:01:36
* @Last Modified by:   anchen
* @Last Modified time: 2016-07-09 10:01:05
*/

define([
  'jquery',
  'underscore',
  'backbone',
   'jstz',
  'bootstrap'
], function ($, _, backbone,jstz) {

var dialogView = Backbone.View.extend({
    /* el: '#listcontent',*/
    el:'#modaldialog',

    hasajax : false,


    initialize: function () {

      console.log('dialog init');
      //_.bindAll(this);
    },

    events: {
      'click #searchbtn': 'searchform',
      'submit form' : 'submitForm'
    },

    render: function () {
        //console.log('searchView');
        $("#homepage").show();
        return this;
    },


    getdialog: function(){

        var that = this;
         return  $.ajax({
                url:"infotest.php",
                type:'GET',
                async:true,
                data:{time_zone:jstz.determine().name()},
                success:function(data){
                    that.hasajax = true;
                    //dialoginfo
                   var  getvisitinfo = $.parseJSON(data);
                   $("#dialoginfo").html(getvisitinfo['data']);
                },
                error:function(){

                }
            });
    },

    opendialog : function(){
        $("#myModal").modal('show');
    },
    closedialog : function(){
        $("#myModal").modal('hide');
    }
  });

 var instance;

return function(){
    if(!instance){
        return instance = new dialogView();
    }else{
        return instance;
    }
}
  //return listView;
});